package com.dex4d.ui.qr;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.dex4d.R;
import com.dex4d.core.AppToolBarBaseActivity;
import com.dex4d.ui.qr.fragment.EasyErrorCodeFragment;
import com.dex4d.ui.qr.fragment.EasyLoginAuthFragment;
import com.dex4d.ui.qr.fragment.EasyPayAuthFragment;
import com.king.zxing.Intents;

/**
 * 认证确认
 */
public class EasyAuthActivity extends AppToolBarBaseActivity {

    public static void start(Activity activity, String result) {
        Intent intent = new Intent(activity, EasyAuthActivity.class);
        intent.putExtra(Intents.Scan.RESULT, result);
        activity.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_easy_auth;
    }

    @Override
    protected void initVariables() {
        String result = getIntent().getStringExtra(Intents.Scan.RESULT);
        if (result.contains("qrlogin")) {//扫码登录
            getSupportFragmentManager().beginTransaction().add(R.id.container, EasyLoginAuthFragment.newInstance(result)).commit();
        } else if (result.contains("qrpay")) {//扫码支付签名
            getSupportFragmentManager().beginTransaction().add(R.id.container, EasyPayAuthFragment.newInstance(result)).commit();
        } else {
            getSupportFragmentManager().beginTransaction().add(R.id.container, EasyErrorCodeFragment.newInstance(result)).commit();
        }
    }

    @Override
    protected void loadData() {

    }

    @Override
    protected void initToolbar() {
        showBackView();
    }
}
